package com.sneakxy.cloudbase.platform.http;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.StringUtils;
import org.springframework.session.web.http.CookieSerializer.CookieValue;

import com.google.common.collect.Lists;
import com.sneakxy.cloudbase.platform.utils.feign.TokenHolder;

public class TokenCookieValueHandler implements CookieValueHandler {

	@Override
	public List<String> readCookieValues(HttpServletRequest request) {
		String sessionId = request.getHeader(TokenHolder.TOKEN_NAME);
		if(StringUtils.isNotBlank(sessionId)) {
			List<String> headerSessionIds = new ArrayList<>();
			headerSessionIds.add(sessionId);
			return headerSessionIds;
		}
		return Lists.newArrayList();
	}

	@Override
	public void writeCookieValue(CookieValue cookieValue) {
		//不需要保存cookie
	}

}
